package ru.dc.object.commands;

import org.apache.commons.lang.StringUtils;

import java.util.Arrays;

/**
 * <pre>
 * User: Penkov Vladimir
 * Date: 11.10.2010
 * Time: 10:48:30
 * </pre>
 */
public class Supports extends Command {

    private String[] features;

    @Override
    public String generateCommand() {
        return getActualCommandName()+" "+ StringUtils.join(features, " ");
    }

    @Override
    public String getActualCommandName() {
        return "$Supports";
    }

    @Override
    public void parseCommand() {
        final int index = getActualCommandName().length() + 1;
        if (getCommand().length()>index) {
            String featuresStr = getCommand().substring(index);
            features = featuresStr.split(" ");
        }
        else {
            features = null;
        }
    }

    public String[] getFeatures() {
        return features;
    }

    public void setFeatures(String... features) {
        this.features = features;
    }


    @Override
    public String toString() {
        return "Supports{" +
                "features=" + (features == null ? null : Arrays.asList(features)) +
                '}';
    }
}
